﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Pibby.Core.IO.Tests
{
	[TestClass]
	public class WellKnownFoldersTests
	{
		[TestMethod]
		public void WellKnownFolders_BrowsingForFolder_KnownBaseFolder_ShowShorterFriendlyForm()
		{
			var folders = new WellKnownFolders();

			string browsedFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);

			string friendlyForm = folders.Translate(browsedFolder);

			Assert.AreEqual("MyMusic", friendlyForm);
		}

		[TestMethod]
		public void WellKnownFolders_BrowsingForFolder_KnownBaseFolder_SubFolder_ShowShorterFriendlyForm()
		{
			var folders = new WellKnownFolders();

			string browsedFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic) + "\\Talking Heads";

			string friendlyForm = folders.Translate(browsedFolder);

			Assert.AreEqual("MyMusic\\Talking Heads", friendlyForm);
		}

		[TestMethod]
		public void WellKnownFolders_BrowsingForFolder_UnknownBaseFolder_DoesNotTranslate()
		{
			var folders = new WellKnownFolders();

			string browsedFolder = "C:\\This\\Is\\Not\\A\\Known\\Folder";

			string friendlyForm = folders.Translate(browsedFolder);

			Assert.AreEqual(browsedFolder, friendlyForm);
		}

		[TestMethod]
		public void WellKnownFolders_GivenFriendlyForm_ConvertsToFullPath()
		{
			var folders = new WellKnownFolders();

			string friendlyForm = "MyMusic";

			string fullPath = folders.Untranslate(friendlyForm);

			Assert.AreEqual(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic), fullPath);
		}

		[TestMethod]
		public void WellKnownFolders_GivenFriendlyForm_SubFolder_ConvertsToFullPath()
		{
			var folders = new WellKnownFolders();

			string friendlyForm = "MyMusic\\REM";

			string fullPath = folders.Untranslate(friendlyForm);

			Assert.AreEqual(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic) + "\\REM", fullPath);
		}

	}
}
